import { PolylineEdge, PolylineEdgeModel, LogicFlow } from '@logicflow/core';
import EdgeTextTheme = LogicFlow.EdgeTextTheme;

class SequenceModel extends PolylineEdgeModel {
    // 设置边样式
    getEdgeStyle() {
        const style = super.getEdgeStyle();
        const { properties } = this;
        if (properties.isstrokeDashed) {
            style.strokeDasharray = '4, 4';
        }
        style.stroke = 'orange';
        return style;
    }

    // 设置边文本样式
    getTextStyle() {
        const style: EdgeTextTheme = super.getTextStyle();
        style.color = '#3451F1';
        style.fontSize = 20;
        style.background = Object.assign({}, style.background, {
            fill: '#F2F131',
        });
        return style;
    }

    // 设置 hover 轮廓样式
    getOutlineStyle() {
        const style = super.getOutlineStyle();
        style.stroke = 'blue';
        return style;
    }
    setAttributes() {
        this.isAnimation = true
    }

    getEdgeAnimationStyle() {
        const style = super.getEdgeAnimationStyle()
        style.strokeDasharray = '5 5'
        style.animationDuration = '10s'
        style.stroke  = '#7ebf7a'
        return style
    }
}
export default function registerEdgeDone(lf:LogicFlow) {
    lf.register({
        type: 'edgeDone',
        view: PolylineEdge,
        model: SequenceModel,
    })
}
